package kr.co.boogui.actions.member;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import kr.co.boogui.actions.ActionHandler;
import kr.co.boogui.dao.MemberDAO;
import kr.co.boogui.model.MemberVO;

public class MemberRemoveAction implements ActionHandler {
	@Override
	public String execute(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		String viewPage = "f|/WEB-INF/jsp/tiles/index.jsp";

		HttpSession sess = req.getSession();
		MemberVO m = new MemberVO();
		m.setMno((String) sess.getAttribute("mno"));

		if (req.getMethod().equalsIgnoreCase("get")) {

			req.setAttribute("readmember", MemberDAO.readMember(m));
			req.setAttribute("action", "../member/member_remove.jsp");
		} else if (req.getMethod().equalsIgnoreCase("post")) {
			viewPage = "r|index.bi";

			MemberDAO.deleteMember(m);
			sess.invalidate();
		}

		return viewPage;
	}

}
